# 17/100 数组-缺失的第一个正数
# leetcode第41题: https://leetcode.cn/problems/first-missing-positive/description/?envType=study-plan-v2&envId=top-100-liked
# Date: 2025/1/1

from leetcode.test import test_function as tf


def firstMissingPositive(nums: list[int]) -> int:
    """使用hash算法"""
    uniq = set(nums)
    for i in range(1, len(nums) + 1):
        if i not in uniq:
            return i


if __name__ == '__main__':
    inp = [{"nums": [1, 2, 0]}, {"nums": [3, 4, -1, 1]}, {"nums": [7, 8, 9, 11, 12]}, {"nums": [0, 2, 2, 1, 1]}, ]
    out = [3, 2, 1, 3]

    tf(firstMissingPositive, inp, out)
